<?php 

require("../include/config.php");
require("../API/php/fonctions.php");
require("../API/php/header.php");

// phpsql/mysql_getLive.php?milis=123450&date=2012-07-30&crtl=ok

//[0][0] = F+ferme
//[0][0] = A+arrive
//[0][0] = O+obj
//[0][0] = S+stock
//[0][0] = ABS+absence
//[0][0] = R+retours
//[0][0] = RM+taux de retour sur le mois
//[0][0] = S3+stock SN3
//[0][0] = FA+fermé d'auj

// IN obligatoire
$arrayGet = array(
    "crtl" => null,
    "date" => null
);

$arrayValeur = recupGet($arrayGet, $bolDecode);

if($arrayValeur["error"] == null){
	// CONNECION SQL
	$db = mysql_connect($host, $base, $mdp)  or die('Erreur de connexion '.mysql_error());
        mysql_query("SET NAMES UTF8"); 

	// CONNECION BASE
	mysql_select_db($base,$db)  or die('Erreur de selection '.mysql_error());

	//les fermés
	$sql = "SELECT count( * ) as ferme
		FROM vue_inventaire_tocs_live a
		WHERE 1=1
		AND a.statut = 'Fermé'
		AND a.emis != 'oui'
		AND a.revision  = 0
		AND a.responsable in (SELECT b.responsable FROM `effectifs` b WHERE 1=1
			AND b.date_in != '0000-00-00' 
			AND b.date_out != '0000-00-00')
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
	;";

	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$strSorti .= 'F&'.$data['ferme']
		.'&'
		."\r\n"; 
	}
	
//------------------------------------------------------------------
	
	//L'arrivée
	$sql = "select count(*) as arrive 
		from vue_inventaire_tocs_live a
		where 1=1
		AND a.date_creation > DATE_FORMAT(NOW(), '%Y-%m-%d')
		AND a.emis != 'oui'
		AND a.revision = 0
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
	;";

	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$strSorti .= 'A&'.$data['arrive']
		.'&'
		."\r\n"; 
	}
	
//------------------------------------------------------------------
	
	//L'objecf
	$sql = "select round((charge * 2 / 10)) as obj
		from affectation
		where 1=1
		AND date = '".$arrayValeur["date"]."'
	;";

	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$strSorti .= 'O&'.$data['obj']
		.'&'
		."\r\n"; 
	}
	
//------------------------------------------------------------------	
	
	//les entrants sur les mois
	$sql = "select count(*) as `recuMois0` from `vm_inventaire_tocs` a
		where 1=1
		AND a.`revision` = 0
		AND a.`emis` != 'Oui'
		AND date_format(a.`date_creation`,'%y-%m') = date_format(now() - interval 0 MONTH,'%y-%m')
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
		AND a.`date_creation` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$strSorti .= 'AM&'.$data['recuMois0']
		.'&'
		."\r\n"; 
	}
	
//------------------------------------------------------------------
	
	//////////////////
	//les fermé sur les mois
	$sql = "select count(*) as `fermeMois0` from `vm_inventaire_tocs` a
		where 1=1
		AND a.`revision` = 0
		AND a.`emis` != 'Oui'
		AND a.`statut` = 'Fermé'
		AND date_format(a.`date_statut`,'%y-%m') = date_format(now() - interval 0 MONTH,'%y-%m')
		AND responsable in (SELECT b.responsable FROM `effectifs` b WHERE 1=1
			AND b.date_in != '0000-00-00' 
			AND b.date_out != '0000-00-00')
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
		AND a.`date_statut` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$strSorti .= 'FM&'.$data['fermeMois0']
		.'&'
		."\r\n"; 
	}
	
//------------------------------------------------------------------	

	//////////////////
	//le stock
	$sql = "SELECT COUNT(*) as stock FROM
		vm_inventaire_tocs a
		WHERE 1=1
		AND a.statut != 'Fermé'
		AND a.emis != 'Oui'
		AND a.date_creation < date_format(now(),'%Y-%m-%d')
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
		AND ((
			a.revision > 0
			AND 
			responsable in (SELECT b.responsable FROM `effectifs` b WHERE 1=1
				AND b.date_in != '0000-00-00' 
				AND b.date_out != '0000-00-00')
		) OR
		a.revision = 0)
		AND a.`date_creation` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$strSorti .= 'S&'.$data['stock']
		.'&'
		."\r\n"; 
	}
	
//------------------------------------------------------------------
	
	//////////////////
	//les retours
	$sql = "SELECT COUNT(*) as retours FROM
		vm_inventaire_tocs a
		WHERE 1=1
		AND a.statut != 'Fermé'
		AND a.emis != 'Oui'
		AND a.date_creation < date_format(now(),'%Y-%m-%d')
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
		AND a.revision > 0
		AND responsable in (SELECT b.responsable FROM `effectifs` b WHERE 1=1
				AND b.date_in != '0000-00-00' 
				AND b.date_out != '0000-00-00')
		AND a.`date_creation` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$strSorti .= 'R&'.$data['retours']
		.'&'
		."\r\n"; 
	}
	
//------------------------------------------------------------------
	
	//////////////////
	//les absences
	$strAbs = "";
	
	$sql = "SELECT b.responsable FROM `effectifs` b WHERE 1=1
				AND b.date_in != '0000-00-00' 
				AND b.date_out != '0000-00-00'
				AND b.date_out > date_format(now(),'%Y-%m-%d')
	;";
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$sql2 = "select `".$data['responsable']."` as coll from affectation where 1=1 and `date` = date_format(now(),'%Y-%m-%d');";
		$req2 = mysql_query($sql2) or die('Erreur SQL !<br>'.$sql2.'<br>'.mysql_error()); 
		
		while($data2 = mysql_fetch_assoc($req2)) 
		{ 
			if($data2['coll']==0){
				$strAbs .= ",".$data['responsable'];
			}
		}
	}
	
	$strSorti .= 'ABS&'.substr($strAbs, 1)
		.'&'
		."\r\n"; 
	
//------------------------------------------------------------------
		
	//nb p1
	$sql = "SELECT count(*) as 'nbTocP10' FROM
		vm_inventaire_tocs a, vm_durees b
		WHERE 1=1
		AND a.id_toc = b.id_toc
		AND a.revision = 0
		AND a.emis != 'Oui'
		AND a.statut = 'Fermé'
		AND a.priorite = 'P1-Bloquant'
		AND date_format(a.`date_statut`,'%y-%m') = date_format(now() - interval 0 MONTH,'%y-%m')
		AND a.`date_statut` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		AND a.responsable in (SELECT c.responsable FROM `effectifs` c WHERE 1=1
			AND c.date_in != '0000-00-00' 
			AND c.date_out != '0000-00-00'  
			)
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
		AND a.date_creation >= (SELECT STR_TO_DATE(param_value,'%Y-%m-%d') FROM tab_parametres c WHERE 1=1 AND c.param_name = 'date_hpas')
	;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$nbTocP10 = $data['nbTocP10'];
	}
	
	//nb p1 ferme
	$sql = "SELECT count(*) as 'nbTocP1D0' FROM
		vm_inventaire_tocs a, vm_durees b
		WHERE 1=1
		AND a.id_toc = b.id_toc
		AND a.revision = 0
		AND a.emis != 'Oui'
		AND a.statut = 'Fermé'
		AND a.priorite = 'P1-Bloquant'
		AND b.duree_reel <= 480
		AND date_format(a.`date_statut`,'%y-%m') = date_format(now() - interval 0 MONTH,'%y-%m')
		AND a.`date_statut` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		AND a.responsable in (SELECT c.responsable FROM `effectifs` c WHERE 1=1
			AND c.date_in != '0000-00-00' 
			AND c.date_out != '0000-00-00'  
			)
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
		AND a.date_creation >= (SELECT STR_TO_DATE(param_value,'%Y-%m-%d') FROM tab_parametres c WHERE 1=1 AND c.param_name = 'date_hpas')
	;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$nbTocP1D0 = $data['nbTocP1D0'];
	}
	
	if($nbTocP10 != 0){
		$percSLAP10 = round(($nbTocP1D0 / $nbTocP10) * 100,2);
	}else{
		$percSLAP10 = 0;
	}
	$strSorti .= 'SLAP1&'.$percSLAP10
	.'&'
	."\r\n";
//------------------------------------------------------------------

	//nb p2
	$sql = "SELECT count(*) as 'nbTocP20' FROM
		vm_inventaire_tocs a, vm_durees b
		WHERE 1=1
		AND a.id_toc = b.id_toc
		AND a.revision = 0
		AND a.emis != 'Oui'
		AND a.statut = 'Fermé'
		AND a.priorite = 'P2-Majeur'
		AND date_format(a.`date_statut`,'%y-%m') = date_format(now() - interval 0 MONTH,'%y-%m')
		AND a.`date_statut` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		AND a.responsable in (SELECT c.responsable FROM `effectifs` c WHERE 1=1
			AND c.date_in != '0000-00-00' 
			AND c.date_out != '0000-00-00'  
			)
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
		AND a.date_creation >= (SELECT STR_TO_DATE(param_value,'%Y-%m-%d') FROM tab_parametres c WHERE 1=1 AND c.param_name = 'date_hpas')
	;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$nbTocP20 = $data['nbTocP20'];
	}
	
	//nb p2 ferme dans SLA
	$sql = "SELECT count(*) as 'nbTocP2D0' FROM
		vm_inventaire_tocs a, vm_durees b
		WHERE 1=1
		AND a.id_toc = b.id_toc
		AND a.revision = 0
		AND a.emis != 'Oui'
		AND a.statut = 'Fermé'
		AND a.priorite = 'P2-Majeur'
		AND b.duree_reel <= 960
		AND date_format(a.`date_statut`,'%y-%m') = date_format(now() - interval 0 MONTH,'%y-%m')
		AND a.`date_statut` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		AND a.responsable in (SELECT c.responsable FROM `effectifs` c WHERE 1=1
			AND c.date_in != '0000-00-00' 
			AND c.date_out != '0000-00-00'  
			)
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
		AND a.date_creation >= (SELECT STR_TO_DATE(param_value,'%Y-%m-%d') FROM tab_parametres c WHERE 1=1 AND c.param_name = 'date_hpas')
	;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$nbTocP2D0 = $data['nbTocP2D0'];
	}
	
	if($nbTocP20 != 0){
		$percSLAP20 = round(($nbTocP2D0 / $nbTocP20) * 100,2);
	}else{
		$percSLAP20 = 0;
	}
	$strSorti .= 'SLAP2&'.$percSLAP20
	.'&'
	."\r\n";
	
//------------------------------------------------------------------

	//nombre de ticket aquité sur 12mois
	$sql = "SELECT count(*) as 'nbTocP340' FROM
		vm_inventaire_tocs a, vm_durees b
		WHERE 1=1
		AND a.id_toc = b.id_toc
		AND a.revision = 0
		AND a.emis != 'Oui'
		AND a.statut = 'Fermé'
		AND (a.priorite = 'P3-Mineur' or a.priorite = 'P4-Mineur')
		AND date_format(a.`date_statut`,'%y-%m') = date_format(now() - interval 0 MONTH,'%y-%m')
		AND a.`date_statut` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		AND a.responsable in (SELECT c.responsable FROM `effectifs` c WHERE 1=1
			AND c.date_in != '0000-00-00' 
			AND c.date_out != '0000-00-00' 
			)
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
		AND a.date_creation >= (SELECT STR_TO_DATE(param_value,'%Y-%m-%d') FROM tab_parametres c WHERE 1=1 AND c.param_name = 'date_hpas')
	;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$nbTocP340 = $data['nbTocP340'];
	}
	
	//nombre de ticket aquité sur 12mois
	$sql = "SELECT count(*) as 'nbTocP34D0' FROM
		vm_inventaire_tocs a, vm_durees b
		WHERE 1=1
		AND a.id_toc = b.id_toc
		AND a.revision = 0
		AND a.emis != 'Oui'
		AND a.statut = 'Fermé'
		AND (a.priorite = 'P3-Mineur' or a.priorite = 'P4-Mineur')
		AND b.duree_reel <= 2400
		AND date_format(a.`date_statut`,'%y-%m') = date_format(now() - interval 0 MONTH,'%y-%m')
		AND a.`date_statut` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		AND a.responsable in (SELECT c.responsable FROM `effectifs` c WHERE 1=1
			AND c.date_in != '0000-00-00' 
			AND c.date_out != '0000-00-00' 
			)
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
		AND a.date_creation >= (SELECT STR_TO_DATE(param_value,'%Y-%m-%d') FROM tab_parametres c WHERE 1=1 AND c.param_name = 'date_hpas')
	;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$nbTocP34D0 = $data['nbTocP34D0'];
	}
	
	if($nbTocP340 != 0){
		$percSLAP340 = round(($nbTocP34D0 / $nbTocP340) * 100,2);
	}else{
		$percSLAP340 = 0;
	}
	$strSorti .= 'SLAP34&'.$percSLAP340
	.'&'
	."\r\n";	
	
//------------------------------------------------------------------
	// entrant hier
	$sql = "SELECT count(*) as 'arrive' FROM
		vm_inventaire_tocs a
		WHERE 1=1
		AND a.revision = 0
		AND a.emis != 'Oui'
		AND date_format(a.date_creation,'%Y-%m-%d') = (select date from affectation
			where 1=1
			and id = (select max(id) from affectation
				where 1=1
				and open != close
				and date < date_format(now(),'%Y-%m-%d')
				order by date desc))
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
	;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// Fiches reçues dans la journée  
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$strSorti .= 'AJ&'.$data['arrive']
		."&"
		."\r\n"; 
	}
	
//------------------------------------------------------------------
	// ferme hier
	$sql = "SELECT count(*) as 'ferme' FROM
		vm_inventaire_tocs a
		WHERE 1=1
		AND a.revision = 0
		AND a.emis != 'Oui'
		AND a.statut = 'Fermé'
		AND date_format(a.date_statut,'%Y-%m-%d') = (select date from affectation
			where 1=1
			and id = (select max(id) from affectation
				where 1=1
				and open != close
				and date < date_format(now(),'%Y-%m-%d')
				order by date desc))
		AND responsable in (SELECT b.responsable FROM `effectifs` b WHERE 1=1
			AND b.date_in != '0000-00-00' 
			AND b.date_out != '0000-00-00')
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
	;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// Fiches reçues dans la journée  
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$strSorti .= 'FJ&'.$data['ferme']
		."&"
		."\r\n"; 
	}
	
//------------------------------------------------------------------
	
	//Les P1 pas affecté
	$sql = "SELECT id_toc_ori, id_toc 
	FROM `vue_inventaire_tocs_live` 
	where 1=1 
	and (`responsable` = 'SYS' or `responsable` = 'PILOTE') 
	AND `priorite` like '%P1%'
	AND emis != 'oui'
	AND revision = 0
	;";

	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$strSorti .= 'P1&'.$data['id_toc_ori'].'&'.$data['id_toc'].'&'
		."\r\n"; 
	}
	
//------------------------------------------------------------------
	
	//Les P2 pas affecté
	$sql = "SELECT id_toc_ori, id_toc 
	FROM `vue_inventaire_tocs_live` 
	where 1=1 
	and (`responsable` = 'SYS' or `responsable` = 'PILOTE') 
	AND `priorite` like '%P2%'
	AND emis != 'oui'
	AND revision = 0
	;";

	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$strSorti .= 'P2&'.$data['id_toc_ori'].'&'.$data['id_toc'].'&'
		."\r\n"; 
	}
	
//------------------------------------------------------------------	
	
	//les retour sur les mois
	$sql = "select count(*) as `retourMois` from `vm_inventaire_tocs` a
		where 1=1
		AND a.`revision` != 0
		AND a.`emis` != 'Oui'
		AND date_format(a.`date_creation`,'%y-%m') = date_format(now() - interval 0 MONTH,'%y-%m')
		AND a.`date_statut` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
		;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$strSorti .= 'RM&'.$data['retourMois']
		.'&'
		."\r\n"; 
	}

//------------------------------------------------------------------
	//stock sn3
	$sql = "SELECT count(*) as 'stock_sn3' FROM
		vm_inventaire_tocs a
		WHERE 1=1
		AND a.emis != 'Oui'
		AND a.statut in ('Réception','Pris en main','En Analyse','Correction')
		AND a.`date_statut` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
	;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 
	
	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$strSorti .= 'S3&'.$data['stock_sn3']
		."&"
		."\r\n"; 
	}
	
//------------------------------------------------------------------
	//fermé créer même jour
	$sql = "SELECT count( * ) as ferme_auj
		FROM vue_inventaire_tocs_live a
		WHERE 1=1
		AND a.statut = 'Fermé'
		AND a.emis != 'oui'
		AND a.revision  = 0
		AND a.responsable in (SELECT b.responsable FROM `effectifs` b WHERE 1=1
			AND b.date_in != '0000-00-00' 
			AND b.date_out != '0000-00-00')
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
		AND DATE_FORMAT(a.date_creation, '%Y-%m-%d') = a.date_statut 
	;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 
	
	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$strSorti .= 'FA&'.$data['ferme_auj']
		."&"
		."\r\n"; 
	}

	// DECONNECION SQL
	mysql_close();
}else{
	$strSorti = "ERROR:".$arrayValeur["error"];
}

require("../API/php/footer.php");
?>